#include<iostream>
#include<vector>
#include<queue>
#include<cstring>
#include<cmath>
#include<map>
#include<set>
#include<cstdio>
#include<algorithm>
#define debug(a) cout<<#a<<"="<<a<<endl;
using namespace std;
const int maxn=3e5+10;
typedef int LL;
inline LL read(){LL x=0,f=1;char ch=getchar();	while (!isdigit(ch)){if (ch=='-') f=-1;ch=getchar();}while (isdigit(ch)){x=x*10+ch-48;ch=getchar();}
return x*f;}
LL fa[maxn];
LL find(LL x){
    if(x!=fa[x]) return fa[x]=find(fa[x]);
    return fa[x];
}
struct Edge{
    LL u,v,val;
}edges[maxn];
bool cmp(Edge A,Edge B){
    return A.val<B.val;
}
int main(void)
{
  LL n,m,q;n=read();m=read();q=read();
  for(LL i=1;i<=n;i++) fa[i]=i;
  for(LL i=1;i<=m;i++){
    LL u,v,val;u=read();v=read();val=read();
    edges[i].u=u;edges[i].v=v;edges[i].val=val;
  }
  ///sort(edges+1,edges+1+m,cmp);

  while(q--){
    LL opt;opt=read();
    if(opt==1){
        LL x,y,z,t;x=read();y=read();z=read();t=read();
        edges[x].u=y;edges[x].v=z;edges[x].val=t;
    }
    else{
        LL l,r;l=read();r=read();
        for(LL i=1;i<=n;i++){
            fa[i]=i;
        }
        vector<Edge>v;
        for(LL i=l;i<=r;i++){
            v.push_back({edges[i].u,edges[i].v,edges[i].val});
        }
        sort(v.begin(),v.end(),cmp);
        LL ans=0;LL cnt=0;
        for(auto i:v){
            LL u=find(i.u);LL v=find(i.v);
            if(u==v) continue;
            fa[u]=v;
            ans+=i.val;
            cnt++;
        }
        if(cnt<n-1){
            printf("Impossible\n");
        }
        else printf("%d\n",ans);
    }
  }
return 0;
}
